home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Tools / Alpha 6.51b13 ƒ / LaTeX / latex 2.09 / latex.tcl < prev    next >
Text File  |  1996-07-03  |  57KB  |  2,555 lines

  1. #############################################################################
  2. #
  3. # latex.tcl, version 2.0:  macros and bindings for LaTeX users
  4. #
  5. # -- see files 'LaTeX Help' and 'commands.tex' in the Help folder
  6. #
  7. #############################################################################
  8. #
  9. # version 1.1 and 1.2 (11/10/92) by Richard T. Austin (austin@eecs.umich.edu)
  10. # version 2.0 (1/24/93) by Tom Scavo (trscavo@syr.edu)
  11. #
  12. # If you make improvements to this file, please share them!
  13. #
  14. #############################################################################
  15.  
  16. source "$HOME:Tcl:Modes:smart.tcl"
  17.  
  18. #############################################################################
  19. #
  20. # Flags and Variables.
  21. #
  22. #############################################################################
  23.  
  24. set true 1
  25. set false 0
  26. # set insertLatexParameter $true
  27. # set noInsertLatexParameter $false
  28.  
  29. # Flags:
  30. newModeVar TeX optionIsMeta $false 1
  31. newModeVar TeX useBoxMacro $true 1
  32. newModeVar TeX deleteObjectNoisily $true 1
  33. newModeVar TeX deleteEnvironmentNoisily $true 1
  34. newModeVar TeX wordWrap $true 1
  35. newModeVar TeX useStatusBar $true 1
  36.  
  37. # Variables:
  38. newModeVar TeX boxMacroName "BoxedEPSF" 0
  39. newModeVar TeX funcExpr {\\((sub)*section|chapter)(\[.*\]|\*)?{([^{}]*)}} 0
  40. newModeVar TeX prefixString {% } 0
  41. newModeVar TeX wordBreak {(\\)?[a-zA-Z0-9]+} 0
  42. newModeVar TeX wordBreakPreface {([^a-zA-Z0-9\\]|.\\)} 0
  43.  
  44. proc dummyTeX {} {}
  45.  
  46.  
  47. #############################################################################
  48. #
  49. # Utility Macros.
  50. #
  51. #############################################################################
  52.  
  53. # A boolean function which checks to see if there's a current selection.
  54. proc isSelection {} {
  55.     return [string length [getSelect]]
  56. }
  57.  
  58. # Select the line containing the insertion point.
  59. proc lineSelect {} {
  60.     goto [lineStart [getPos]]
  61.     nextLineSelect
  62. }
  63.  
  64. # A boolean function which takes any string and tests to see if
  65. # that string contains all whitespace characters.  Carriage returns 
  66. # are considered whitespace, as are spaces and tabs.
  67. proc isWhitespace {anyString} {
  68.     set len [string length $anyString]
  69.     for {set i 0} {$i < $len} {incr i} {
  70.         set c [string index $anyString $i]
  71.         if {($c != "\ ") && ($c != "\t") && ($c != "\r")} then {return 0}
  72.     }
  73.     return 1
  74. }
  75.  
  76. # Insert a carriage return at the insertion point if any
  77. # character preceding the insertion point (on the same line)
  78. # is a non-whitespace character.
  79. proc openingCarriageReturn {} {
  80.     set end [getPos]
  81.     set start [lineStart $end]
  82.     set text [getText $start $end]
  83.     if {![isWhitespace $text]} carriageReturn
  84. }
  85.  
  86. # Insert a carriage return at the insertion point if any
  87. # character following the insertion point (on the same line)
  88. # is a non-whitespace character.
  89. proc closingCarriageReturn {} {
  90.     set start [getPos]
  91.     set end [nextLineStart $start]
  92.     set text [getText $start $end]
  93.     if {![isWhitespace $text]} carriageReturn
  94. }
  95.  
  96. # Set up tab stop mechanism.
  97. proc gotoTabStop {directionIndicator} {
  98.     set searchResult [search -n -f $directionIndicator -m 0 -i 1 -r 0 {•} [getPos]]
  99.     if {[llength $searchResult] == 0} then {
  100.         message "tab stop not found"
  101.         return 0
  102.     } else {
  103.         goto [lindex $searchResult 0]
  104.         return 1
  105.     }
  106. }
  107. proc nextTabStop {} {
  108.     if {[gotoTabStop 1]} {deleteChar}
  109. }
  110. proc previousTabStop {} {
  111.     if {[gotoTabStop 0]} {deleteChar}
  112. }
  113.  
  114. # Insert an object at the insertion point. If there is a selection and the 
  115. # global variable deleteObjectNoisily is false, quietly delete the selection 
  116. # first (just like "paste"). Otherwise, prompt the user for the appropriate 
  117. # action. Returns true if the object is ultimately inserted, and false if the 
  118. # user cancels the operation. 
  119. proc insertObject {objectName} {
  120.     global deleteObjectNoisily
  121.     if {[isSelection]} then {
  122.         if {$deleteObjectNoisily} then {
  123.             case [askyesno "Delete selection?"] in {
  124.                 "yes" {deleteText [getPos] [selEnd]}
  125.                 "no" {backwardChar}
  126.                 "cancel" {return 0}
  127.             }
  128.         } else {
  129.             deleteText [getPos] [selEnd]
  130.         }
  131.     }
  132.     insertText $objectName
  133.     return 1
  134. }
  135.  
  136. # Insert an object at the insertion point. If there is a selection, wrap 
  137. # it inside the parameters $left and $right. Returns true if there is a 
  138. # selection (in which case it will wrap), and false otherwise. 
  139. proc wrapObject {left right} {
  140.     set currentPos [getPos]
  141.     set selected [isSelection]
  142.     if {$selected} then {
  143.         replaceText $currentPos [selEnd] $left [getSelect] $right
  144.     } else {
  145.         insertText $left "•" $right
  146.     }
  147.     goto $currentPos
  148.     nextTabStop
  149.     return $selected
  150. }
  151.  
  152. # Inserts an environment with the specified name at the insertion point. 
  153. # Preserves indentation, and positions the cursor at the beginning of the 
  154. # environment body (to be inserted by the calling procedure). If the 
  155. # parameter latexParameter is true, a LaTeX parameter is inserted and the 
  156. # cursor is positioned there instead. Deletes the current selection quietly 
  157. # if the global variable deleteEnvironmentNoisily is false; otherwise the 
  158. # user is prompted for directions. Returns true if the environment is 
  159. # ultimately inserted, and false if the user cancels the operation. 
  160. proc insertEnvironment {environmentName latexParameter} {
  161.     global deleteEnvironmentNoisily
  162.     if {[isSelection]} then {
  163.         if {$deleteEnvironmentNoisily} then {
  164.             case [askyesno "Delete selection?"] in {
  165.                 "yes" {deleteText [getPos] [selEnd]}
  166.                 "no" {backwardChar}
  167.                 "cancel" {return 0}
  168.             }
  169.         } else {
  170.             deleteText [getPos] [selEnd]
  171.         }
  172.     }
  173.     set currentPos [getPos]
  174.     openingCarriageReturn
  175.     insertText "\\begin{" $environmentName "}"
  176.     # insert optional LaTeX parameter here:
  177.     if {$latexParameter} {insertText "{•}"}
  178.     carriageReturn
  179.     tab
  180.     insertText "•"
  181.     carriageReturn
  182.     backwardChar
  183.     deleteChar
  184.     insertText "\\end{" $environmentName "}•"
  185.     closingCarriageReturn
  186.     goto $currentPos
  187.     nextTabStop
  188.     return 1
  189. }
  190.  
  191. # Insert an environment with the given name at the insertion point. If there 
  192. # is currently a selection, cut and paste it into the body of the new 
  193. # environment, indent it, and leave it highlighted. Returns true if there is 
  194. # a selection, and false otherwise. 
  195. proc wrapEnvironment {environmentName latexParameter} {
  196.     if {[isSelection]} then {
  197.         set indent [indentString [getPos]]
  198.         set text [getSelect]
  199.         deleteText [getPos] [selEnd]
  200.         insertText $indent "\r"
  201.         backwardChar
  202.         insertEnvironment $environmentName $latexParameter
  203.         if {$latexParameter} then {
  204.             insertText "•"
  205.             nextTabStop
  206.         }
  207.         lineSelect
  208.         clear
  209.         insertText $text
  210.         markHilite
  211.         shiftRight
  212.         return 1
  213.     } else {
  214.         insertEnvironment $environmentName $latexParameter
  215.         return 0
  216.     }
  217. }
  218.  
  219.  
  220. #############################################################################
  221. # Paragraph Mode Macros.
  222. #
  223. #############################################################################
  224.  
  225. # Documents:
  226. proc insertDocument {documentType} {
  227.     set currentPos [getPos]
  228.     insertText "\\documentstyle\[•\]{$documentType}"
  229.     carriageReturn
  230.     insertEnvironment "document" 0
  231.     backwardChar
  232.     deleteChar
  233.     carriageReturn
  234.     insertText "•"
  235.     carriageReturn
  236.     nextTabStop
  237.     carriageReturn
  238.     goto $currentPos
  239.     nextTabStop
  240. }
  241. proc isDocumentSelected {} {
  242.     return 1
  243. }
  244. proc isEmptyFile {} {
  245.     return 1
  246. }
  247. proc wrapDocument {documentType} {
  248.     if {[isSelection]} then {
  249.         if {[isDocumentSelected]} then {
  250.             set text [getSelect]
  251.             deleteText [getPos] [selEnd]
  252.         } else {
  253.             case [askyesno "Select entire document?"] in {
  254.                 "yes" {}
  255.                 "no" {
  256.                     set text [getSelect]
  257.                     deleteText [getPos] [selEnd]
  258.                 }
  259.                 "cancel" {return 0}
  260.             }
  261.         }
  262.         set currentPos [getPos]
  263.         insertDocument $documentType
  264.         insertText "•"
  265.         nextTabStop
  266.         lineSelect
  267.         clear
  268.         insertText $text
  269.         markHilite
  270.         nextTabStop
  271.     } else {
  272.         if {![isEmptyFile]} then {
  273.             case [askyesno "Wrap existing text?"] in {
  274.                 "yes" {}
  275.                 "no" {}
  276.                 "cancel" {return 0}
  277.             }
  278.         }
  279.         insertDocument $documentType
  280.     }
  281.     return 1
  282. }
  283.  
  284. proc letter {} {
  285.     wrapDocument "letter"
  286.     message "type style option(s)"
  287. }
  288. proc article {} {
  289.     wrapDocument "article"
  290.     message "type style option(s)"
  291. }
  292. proc report {} {
  293.     wrapDocument "report"
  294.     message "type style option(s)"
  295. }
  296. proc book {} {
  297.     wrapDocument "book"
  298.     message "type style option(s)"
  299. }
  300.  
  301. proc custom {} {
  302.     catch {prompt "What document type?" "article"} documentType
  303.     if {$documentType != "cancel"} then {
  304.         wrapDocument $documentType
  305.         message "type style option(s)"
  306.     }
  307. }
  308.  
  309. # Sectioning:
  310. proc part {} {
  311.     if {[wrapObject "\\part{" "}•"]} then {
  312.         message "don't forget label"
  313.     } else {
  314.         message "type part name"
  315.     }
  316. }
  317. proc chapter {} {
  318.     if {[wrapObject "\\chapter{" "}•"]} then {
  319.         message "don't forget label"
  320.     } else {
  321.         message "type part name"
  322.     }
  323. }
  324. proc section {} {
  325.     if {[wrapObject "\\section{" "}•"]} then {
  326.         message "don't forget label"
  327.     } else {
  328.         message "type part name"
  329.     }
  330. }
  331. proc subsection {} {
  332.     if {[wrapObject "\\subsection{" "}•"]} then {
  333.         message "don't forget label"
  334.     } else {
  335.         message "type part name"
  336.     }
  337. }
  338. proc subsubsection {} {
  339.     if {[wrapObject "\\subsubsection{" "}•"]} then {
  340.         message "don't forget label"
  341.     } else {
  342.         message "type part name"
  343.     }
  344. }
  345. proc paragraph {} {
  346.     if {[wrapObject "\\paragraph{" "}•"]} then {
  347.         message "don't forget label"
  348.     } else {
  349.         message "type part name"
  350.     }
  351. }
  352. proc subparagraph {} {
  353.     if {[wrapObject "\\subparagraph{" "}•"]} then {
  354.         message "don't forget label"
  355.     } else {
  356.         message "type part name"
  357.     }
  358. }
  359.  
  360. # Definitions:
  361. proc myList {} {alertnote "Not yet implemented."}
  362. proc newcommand {} {alertnote "Not yet implemented."}
  363. proc newenvironment {} {alertnote "Not yet implemented."}
  364. proc newtheorem {} {alertnote "Not yet implemented."}
  365. proc renewcommand {} {alertnote "Not yet implemented."}
  366. proc renewenvironment {} {alertnote "Not yet implemented."}
  367.  
  368. # Text Style:
  369. proc roman {} {
  370.     if {[wrapObject "{\\rm " "}•"]} then {
  371.         message "roman text set"
  372.     } else {
  373.         message "enter roman text"
  374.     }
  375. }
  376. proc bold {} {
  377.     if {[wrapObject "{\\bf " "}•"]} then {
  378.         message "bold text set"
  379.     } else {
  380.         message "enter bold text"
  381.     }
  382. }
  383. proc italic {} {
  384.     if {[wrapObject "{\\it " "\\/}•"]} then {
  385.         insertText "•"
  386.         backwardChar
  387.         backwardChar
  388.     }
  389.     message "italic correction?"
  390. }
  391. proc emphatic {} {
  392.     if {[wrapObject "{\\em " "\\/}•"]} then {
  393.         insertText "•"
  394.         backwardChar
  395.         backwardChar
  396.     }
  397.     message "emphatic correction?"
  398. }
  399. proc slanted {} {
  400.     if {[wrapObject "{\\sl " "\\/}•"]} then {
  401.         insertText "•"
  402.         backwardChar
  403.         backwardChar
  404.     }
  405.     message "italic correction?"
  406. }
  407. proc sansSerif {} {
  408.     if {[wrapObject "{\\sf " "}•"]} then {
  409.         message "sans serif text set"
  410.     } else {
  411.         message "enter sans serif text"
  412.     }
  413. }
  414. proc smallCaps {} {
  415.     if {[wrapObject "{\\sc " "}•"]} then {
  416.         message "small caps text set"
  417.     } else {
  418.         message "enter small caps text"
  419.     }
  420. }
  421. proc typewriter {} {
  422.     if {[wrapObject "{\\tt " "}•"]} then {
  423.         message "typewriter text set"
  424.     } else {
  425.         message "enter typewriter text"
  426.     }
  427. }
  428.  
  429. # Text Size:
  430. proc tiny {} {
  431.     if {[wrapObject "{\\tiny " "}•"]} then {
  432.         message "tiny text set"
  433.     } else {
  434.         message "enter tiny text"
  435.     }
  436. }
  437. proc smallest {} {
  438.     if {[wrapObject "{\\scriptsize " "}•"]} then {
  439.         message "scriptsize text set"
  440.     } else {
  441.         message "enter scriptsize text"
  442.     }
  443. }
  444. proc smaller {} {
  445.     if {[wrapObject "{\\footnotesize " "}•"]} then {
  446.         message "footnotesize text set"
  447.     } else {
  448.         message "enter footnotesize text"
  449.     }
  450. }
  451. proc small {} {
  452.     if {[wrapObject "{\\small " "}•"]} then {
  453.         message "small text set"
  454.     } else {
  455.         message "enter small text"
  456.     }
  457. }
  458. proc normal {} {
  459.     if {[wrapObject "{\\normalsize " "}•"]} then {
  460.         message "normalsize text set"
  461.     } else {
  462.         message "enter normalsize text"
  463.     }
  464. }
  465. proc large {} {
  466.     if {[wrapObject "{\\large " "}•"]} then {
  467.         message "large text set"
  468.     } else {
  469.         message "enter large text"
  470.     }
  471. }
  472. proc larger {} {
  473.     if {[wrapObject "{\\Large " "}•"]} then {
  474.         message "Large text set"
  475.     } else {
  476.         message "enter Large text"
  477.     }
  478. }
  479. proc largest {} {
  480.     if {[wrapObject "{\\LARGE " "}•"]} then {
  481.         message "LARGE text set"
  482.     } else {
  483.         message "enter LARGE text"
  484.     }
  485. }
  486. proc huge {} {
  487.     if {[wrapObject "{\\huge " "}•"]} then {
  488.         message "huge text set"
  489.     } else {
  490.         message "enter huge text"
  491.     }
  492. }
  493. proc gigantic {} {
  494.     if {[wrapObject "{\\Huge " "}•"]} then {
  495.         message "Huge text set"
  496.     } else {
  497.         message "enter Huge text"
  498.     }
  499. }
  500.  
  501. # International:  not yet implemented.
  502.  
  503. # Environments:
  504. proc enumerate {} {
  505.     catch {prompt "enumerate:  how many items?" 3} numberItems
  506.     if {$numberItems != "cancel"} then {
  507.         set currentPos [getPos]
  508.         if {[insertEnvironment "enumerate" 0]} then {
  509.             item
  510.             insertText "  •"
  511.             for {set i 1} {$i < $numberItems} {incr i} {
  512.                 carriageReturn
  513.                 carriageReturn
  514.                 item
  515.                 insertText "  •"
  516.             }
  517.             goto $currentPos
  518.             nextTabStop
  519.             message "Type first item"
  520.         }
  521.     }
  522. }
  523. proc itemize {} {
  524.     catch {prompt "itemize:  how many items?" 3} numberItems
  525.     if {$numberItems != "cancel"} then {
  526.         set currentPos [getPos]
  527.         if {[insertEnvironment "itemize" 0]} then {
  528.             item
  529.             insertText "  •"
  530.             for {set i 1} {$i < $numberItems} {incr i} {
  531.                 carriageReturn
  532.                 carriageReturn
  533.                 item
  534.                 insertText "  •"
  535.             }
  536.             goto $currentPos
  537.             nextTabStop
  538.             message "Type first item"
  539.         }
  540.     }
  541. }
  542. proc description {} {
  543.     catch {prompt "description: how many items?" 3} numberItems
  544.     if {$numberItems != "cancel"} then {
  545.         set currentPos [getPos]
  546.         if {[insertEnvironment "description" 0]} then {
  547.             item
  548.             insertText "\[•\]  •"
  549.             for {set i 1} {$i < $numberItems} {incr i} {
  550.                 carriageReturn
  551.                 carriageReturn
  552.                 item
  553.                 insertText "\[•\]  •"
  554.             }
  555.             goto $currentPos
  556.             nextTabStop
  557.             message "Type first item"
  558.         }
  559.     }
  560. }
  561.  
  562. proc insertRow {jmax} {
  563.     insertText "•"
  564.     for {set j 1} {$j < $jmax} {incr j} {
  565.         insertText " & •"
  566.     }
  567. }
  568. proc tabular {} {
  569.     catch {prompt "tabular:  how many rows?" 3} numberRows
  570.     if {$numberRows != "cancel"} then {
  571.         catch {prompt "tabular:  how many columns?" 3} numberCols
  572.         if {$numberCols != "cancel"} then {
  573.             if {[insertEnvironment "tabular" 1]} then {
  574.                 set beginArgument [getPos]
  575.                 insertText "|"
  576.                 for {set j 1} {$j <= $numberCols} {incr j} {
  577.                     insertText "c|"
  578.                 }
  579.                 set endArgument [getPos]
  580.                 nextTabStop
  581.                 insertText "\\hline"
  582.                 for {set i 1} {$i <= $numberRows} {incr i} {
  583.                     carriageReturn
  584.                     insertRow $numberCols
  585.                     insertText "  \\\\"
  586.                     carriageReturn
  587.                     insertText "\\hline"
  588.                 }
  589.                 goto $beginArgument
  590.                 setMark
  591.                 goto $endArgument
  592.                 markHilite
  593.                 message "modify argument?"
  594.             }
  595.         }
  596.     }
  597. }
  598. proc tabbing {} {alertnote "Not yet implemented."}
  599.  
  600. proc figure {} {
  601.     global useBoxMacro
  602.     global boxMacroName
  603.     if {$useBoxMacro} then {
  604.         set currentPos [getPos]
  605.         if {[insertEnvironment "figure" 0]} then {
  606.             insertText "\\centerline{\\$boxMacroName{•}}"
  607.         } else {
  608.             return
  609.         }
  610.     } else {
  611.         if {[wrapEnvironment "figure" 0]} then {
  612.             forwardChar
  613.             backwardChar
  614.             set currentPos [getPos]
  615.         } else {
  616.             set currentPos [getPos]
  617.             insertText "•"
  618.         }
  619.     }
  620.     carriageReturn
  621.     insertText "\\caption{•}"
  622.     carriageReturn
  623.     insertText "\\protect\\label{•}"
  624.     goto $currentPos
  625.     nextTabStop
  626. }
  627. proc table {} {
  628.     if {[wrapEnvironment "table" 0]} then {
  629.         forwardChar
  630.         backwardChar
  631.         set currentPos [getPos]
  632.     } else {
  633.         set currentPos [getPos]
  634.         insertText "•"
  635.     }
  636.     carriageReturn
  637.     insertText "\\caption{•}"
  638.     carriageReturn
  639.     insertText "\\protect\\label{•}"
  640.     goto $currentPos
  641.     nextTabStop
  642. }
  643. proc slide {} {
  644.     wrapEnvironment "slide" 1
  645.     message "enter colors"
  646. }
  647.  
  648. proc verbatim {} {wrapEnvironment "verbatim" 0}
  649. proc quote {} {wrapEnvironment "quote" 0}
  650. proc quotation {} {wrapEnvironment "quotation" 0}
  651. proc verse {} {wrapEnvironment "verse" 0}
  652.  
  653. proc index {} {alertnote "Not yet implemented."}
  654. proc bibliography {} {
  655.     catch {prompt "bibliography:  how many bibitems?" 3} numberItems
  656.     if {$numberItems != "cancel"} then {
  657.         if {[insertEnvironment "thebibliography" 1]} then {
  658.             set beginArgument [getPos]
  659.             insertText "99"
  660.             set endArgument [getPos]
  661.             nextTabStop
  662.             insertText "\\bibitem{•}"
  663.             carriageReturn
  664.             insertText "•"
  665.             for {set i 1} {$i < $numberItems} {incr i} {
  666.                 carriageReturn
  667.                 carriageReturn
  668.                 insertText "\\bibitem{•}"
  669.                 carriageReturn
  670.                 insertText "•"
  671.             }
  672.             goto $beginArgument
  673.             setMark
  674.             goto $endArgument
  675.             markHilite
  676.             message "modify argument?"
  677.         }
  678.     }
  679. }
  680.  
  681. proc general {} {
  682.     catch {prompt "What environment?" "center"} environmentName
  683.     if {$environmentName != "cancel"} {wrapEnvironment $environmentName 0}
  684. }
  685.  
  686. # Boxes:
  687. proc mbox {} {
  688.     if {[wrapObject "\\mbox{" "}•"]} then {
  689.         message "mbox set"
  690.     } else {
  691.         message "enter text"
  692.     }
  693. }
  694. proc fbox {} {alertnote "Not yet implemented."}
  695. proc parbox {} {alertnote "Not yet implemented."}
  696.  
  697. # Misc:
  698. proc ellipsis {} {insertObject "\\ldots"}
  699. proc sectionMark {} {insertObject "\\S"}
  700. proc paragraphMark {} {insertObject "\\P"}
  701. proc dagger {} {insertObject "\\dag"}
  702. proc dblDagger {} {insertObject "\\ddag"}
  703. proc copyright {} {insertObject "\\copyright"}
  704. proc pounds {} {insertObject "\\pounds"}
  705. proc {en-dash} {} {insertObject "--"}
  706. proc {em-dash} {} {insertObject "---"}
  707. proc texLogo {} {insertObject "\\TeX"}
  708. proc latexLogo {} {insertObject "\\LaTeX"}
  709. proc today {} {insertObject "\\today"}
  710.  
  711. proc quotes {} {
  712.     if {[wrapObject "`" "'•"]} then {
  713.         message "text quoted"
  714.     } else {
  715.         message "enter text"
  716.     }
  717. }
  718. proc dblQuotes {} {
  719.     if {[wrapObject "``" "''•"]} then {
  720.         message "text double quoted"
  721.     } else {
  722.         message "enter text"
  723.     }
  724. }
  725. proc note {} {
  726.     if {[wrapObject "\\marginpar{" "}•"]} then {
  727.         message "marginal note set"
  728.     } else {
  729.         message "enter marginal note"
  730.     }
  731. }
  732. proc footnote {} {
  733.     if {[wrapObject "\\footnote{" "}•"]} then {
  734.         message "footnote set"
  735.     } else {
  736.         message "enter footnote"
  737.     }
  738. }
  739. proc label {} {
  740.     if {[wrapObject "\\label{" "}•"]} then {
  741.         message "label defined"
  742.     } else {
  743.         message "enter label"
  744.     }
  745. }
  746. proc crossRef {} { 
  747.     if {[wrapObject "\\ref{" "}•"]} then {
  748.         message "cross-reference made"
  749.     } else {
  750.         message "enter cross-reference"
  751.     }
  752. }
  753. proc pageRef {} { 
  754.     if {[wrapObject "\\pageref{" "}•"]} then {
  755.         message "page reference made"
  756.     } else {
  757.         message "enter page reference"
  758.     }
  759. }
  760. proc citation {} {
  761.     if {[wrapObject "\\cite{" "}•"]} then {
  762.         message "citation made"
  763.     } else {
  764.         message "enter citation"
  765.     }
  766. }
  767. proc item {} {insertObject "\\item"}
  768. proc bibitem {} {
  769.     if {[wrapObject "\\bibitem{" "}•"]} then {
  770.         message "bibitem set"
  771.     } else {
  772.         message "enter bibitem"
  773.     }
  774. }
  775.  
  776.  
  777. #############################################################################
  778. # Math Mode Macros.
  779. #
  780. #############################################################################
  781.  
  782. # Modes:
  783. proc texMath {} {
  784.     if {[wrapObject "$" "$•"]} then {
  785.         message "formula set"
  786.     } else {
  787.         message "enter formula"
  788.     }
  789. }
  790. proc texDisplaymath {} {
  791.     if {[wrapObject "$$" "$$•"]} then {
  792.         message "displayed formula set"
  793.     } else {
  794.         message "enter displayed formula"
  795.     }
  796. }
  797. proc latexMath {} {
  798.     if {[wrapObject "\\( " " \\)•"]} then {
  799.         message "formula set"
  800.     } else {
  801.         message "enter formula"
  802.     }
  803. }
  804. proc latexDisplaymath {} {
  805.     if {[wrapObject "\\\[ " " \\\]•"]} then {
  806.         message "displayed formula set"
  807.     } else {
  808.         message "enter displayed formula"
  809.     }
  810. }
  811.  
  812. # Environments:
  813. proc math {} {wrapEnvironment "math" 0}
  814. proc displaymath {} {wrapEnvironment "displaymath" 0}
  815. proc equation {} {
  816.     if {[wrapEnvironment "equation" 0]} then {
  817.         forwardChar
  818.         backwardChar
  819.         set currentPos [getPos]
  820.     } else {
  821.         set currentPos [getPos]
  822.         insertText "•"
  823.     }
  824.     carriageReturn
  825.     insertText "\\label{•}"
  826.     goto $currentPos
  827.     nextTabStop
  828. }
  829. proc myArray {} {
  830.     catch {prompt "array:  how many rows?" 3} numberRows
  831.     if {$numberRows != "cancel"} then {
  832.         catch {prompt "array:  how many columns?" 3} numberCols
  833.         if {$numberCols != "cancel"} then {
  834.             if {[insertEnvironment "array" 1]} then {
  835.                 set beginArgument [getPos]
  836.                 for {set j 1} {$j <= $numberCols} {incr j} {
  837.                     insertText "c"
  838.                 }
  839.                 set endArgument [getPos]
  840.                 nextTabStop
  841.                 for {set i 1} {$i < $numberRows} {incr i} {
  842.                     insertRow $numberCols
  843.                     insertText "  \\\\"
  844.                     carriageReturn
  845.                 }
  846.                 insertRow $numberCols
  847.                 goto $beginArgument
  848.                 setMark
  849.                 goto $endArgument
  850.                 markHilite
  851.                 message "modify argument?"
  852.             }
  853.         }
  854.     }
  855. }
  856. proc eqnarray {} {
  857.     catch {prompt "eqnarray:  how many rows?" 3} numberRows
  858.     if {$numberRows != "cancel"} then {
  859.         set currentPos [getPos]
  860.         if {[insertEnvironment "eqnarray" 0]} then {
  861.             for {set i 1} {$i < $numberRows} {incr i} {
  862.                 insertRow 3
  863.                 carriageReturn
  864.                 insertText "\\label{•} \\\\"
  865.                 carriageReturn
  866.             }
  867.             insertRow 3
  868.             carriageReturn
  869.             insertText "\\label{•}"
  870.             goto $currentPos
  871.             nextTabStop
  872.         }
  873.     }
  874. }
  875. proc eqnarrayStar {} {
  876.     catch {prompt "eqnarray*:  how many rows?" 3} numberRows
  877.     if {$numberRows != "cancel"} then {
  878.         set currentPos [getPos]
  879.         if {[insertEnvironment "eqnarray*" 0]} then {
  880.             for {set i 1} {$i < $numberRows} {incr i} {
  881.                 insertRow 3
  882.                 insertText "  \\\\"
  883.                 carriageReturn
  884.             }
  885.             insertRow 3
  886.             goto $currentPos
  887.             nextTabStop
  888.         }
  889.     }
  890. }
  891.  
  892. # Formulas:
  893. proc subscript {} {
  894.     if {[wrapObject "_{" "}•"]} then {
  895.         message "subscript set"
  896.     } else {
  897.         message "enter subscript"
  898.     }
  899. }
  900. proc superscript {} {
  901.     if {[wrapObject "^{" "}•"]} then {
  902.         message "superscript set"
  903.     } else {
  904.         message "enter superscript"
  905.     }
  906. }
  907. proc fraction {} {
  908.     set currentPos [getPos]
  909.     if {[isSelection]} then {
  910.         set selection [getSelect]
  911.         set args [split $selection /]
  912.         set len [llength $args]
  913.         deleteText $currentPos [selEnd]
  914.         if {$len == 1} then {
  915.             # maybe the selection should be deleted in this case?
  916.             insertText "\\frac{" $selection "}{•}•"
  917.             goto $currentPos
  918.             nextTabStop
  919.             message "enter denominator"
  920.         } else {
  921.             set firstArg [lindex $args 0]
  922.             set restArgs [lrange $args 1 [expr $len-1]]
  923.             insertText "\\frac{" $firstArg "}{" [join $restArgs /] "}"
  924.             if {$len > 2} {message "beware of multiple /"}
  925.         }
  926.     } else {
  927.         insertText "\\frac{•}{•}•"
  928.         goto $currentPos
  929.         nextTabStop
  930.         message "enter numerator"
  931.     }
  932. }
  933. proc squareRoot {} {
  934.     if {[wrapObject "\\sqrt{" "}•"]} then {
  935.         message "square root set"
  936.     } else {
  937.         message "enter formula"
  938.     }
  939. }
  940. proc nthRoot {} {
  941.     if {[wrapObject "\\sqrt\[•\]{" "}•"]} then {
  942.         message "enter root"
  943.     } else {
  944.         message "enter root, then formula"
  945.     }
  946. }
  947. proc oneParameter {} {
  948.     catch {prompt "Command name?" "sqrt"} commandName
  949.     if {$commandName != "cancel"} {wrapObject "\\$commandName{" "}•"}
  950. }
  951. proc twoParameters {} {
  952.     catch {prompt "Command name?" "frac"} commandName
  953.     if {$commandName != "cancel"} then {
  954.         set currentPos [getPos]
  955.         if {[insertObject "\\$commandName{•}{•}•"]} then {
  956.             goto $currentPos
  957.             nextTabStop
  958.         }
  959.     }
  960. }
  961.  
  962. # Greek:
  963. proc alpha {} {insertObject "\\alpha"}
  964. proc beta {} {insertObject "\\beta"}
  965. proc gamma {} {insertObject "\\gamma"}
  966. proc delta {} {insertObject "\\delta"}
  967. proc epsilon {} {insertObject "\\epsilon"}
  968. proc zeta {} {insertObject "\\zeta"}
  969. proc eta {} {insertObject "\\eta"}
  970. proc theta {} {insertObject "\\theta"}
  971. proc iota {} {insertObject "\\iota"}
  972. proc kappa {} {insertObject "\\kappa"}
  973. proc lambda {} {insertObject "\\lambda"}
  974. proc mu {} {insertObject "\\mu"}
  975. proc nu {} {insertObject "\\nu"}
  976. proc xi {} {insertObject "\\xi"}
  977. proc pi {} {insertObject "\\pi"}
  978. proc rho {} {insertObject "\\rho"}
  979. proc sigma {} {insertObject "\\sigma"}
  980. proc tau {} {insertObject "\\tau"}
  981. proc upsilon {} {insertObject "\\upsilon"}
  982. proc phi {} {insertObject "\\phi"}
  983. proc chi {} {insertObject "\\chi"}
  984. proc psi {} {insertObject "\\psi"}
  985. proc omega {} {insertObject "\\omega"}
  986.  
  987. proc capGamma {} {insertObject "\\Gamma"}
  988. proc capDelta {} {insertObject "\\Delta"}
  989. proc capTheta {} {insertObject "\\Theta"}
  990. proc capLambda {} {insertObject "\\Lambda"}
  991. proc capXi {} {insertObject "\\Xi"}
  992. proc capPi {} {insertObject "\\Pi"}
  993. proc capSigma {} {insertObject "\\Sigma"}
  994. proc capUpsilon {} {insertObject "\\Upsilon"}
  995. proc capPhi {} {insertObject "\\Phi"}
  996. proc capPsi {} {insertObject "\\Psi"}
  997. proc capOmega {} {insertObject "\\Omega"}
  998.  
  999. proc varEpsilon {} {insertObject "\\varepsilon"}
  1000. proc varTheta {} {insertObject "\\vartheta"}
  1001. proc varPi {} {insertObject "\\varpi"}
  1002. proc varRho {} {insertObject "\\varrho"}
  1003. proc varSigma {} {insertObject "\\varsigma"}
  1004. proc varPhi {} {insertObject "\\varphi"}
  1005.  
  1006. # Binary Ops:
  1007. proc plusOrMinus {} {insertObject "\\pm"}
  1008. proc minusOrPlus {} {insertObject "\\mp"}
  1009. proc multiply {} {insertObject "\\times"}
  1010. proc divide {} {insertObject "\\div"}
  1011. proc asterisk {} {insertObject "\\ast"}
  1012. proc star {} {insertObject "\\star"}
  1013. proc circle {} {insertObject "\\circ"}
  1014. proc bigCircle {} {insertObject "\\bigcirc"}
  1015. proc bullet {} {insertObject "\\bullet"}
  1016. proc centerDot {} {insertObject "\\cdot"}
  1017. proc intersection {} {insertObject "\\cap"}
  1018. proc union {} {insertObject "\\cup"}
  1019. proc logicalAnd {} {insertObject "\\wedge"}
  1020. proc logicalOr {} {insertObject "\\vee"}
  1021. proc setMinus {} {insertObject "\\setminus"}
  1022.  
  1023. # Relations:
  1024. proc notEqual {} {insertObject "\\neq"}
  1025. proc lessOrEqual {} {insertObject "\\leq"}
  1026. proc greaterOrEqual {} {insertObject "\\geq"}
  1027. proc subset {} {insertObject "\\subset"}
  1028. proc superset {} {insertObject "\\supset"}
  1029. proc subsetOrEqual {} {insertObject "\\subseteq"}
  1030. proc supersetOrEqual {} {insertObject "\\supseteq"}
  1031. proc elementOf {} {insertObject "\\in"}
  1032. proc equivalent {} {insertObject "\\equiv"}
  1033. proc similar {} {insertObject "\\sim"}
  1034. proc similarEqual {} {insertObject "\\simeq"}
  1035. proc dotEqual {} {insertObject "\\doteq"}
  1036. proc approximate {} {insertObject "\\approx"}
  1037. proc congruent {} {insertObject "\\cong"}
  1038.  
  1039. # Large Ops:
  1040. proc insertLargeOp {commandName} {
  1041.     set currentPos [getPos]
  1042.     insertText "\\$commandName"
  1043.     insertText "_{•}^{•}•"
  1044.     goto $currentPos
  1045.     nextTabStop
  1046. }
  1047. proc sum {} {insertLargeOp "sum"}
  1048. proc product {} {insertLargeOp "prod"}
  1049. proc integral {} {insertLargeOp "int"}
  1050. proc bigUnion {} {insertLargeOp "bigcup"}
  1051. proc bigIntersection {} {insertLargeOp "bigcap"}
  1052. proc bigAnd {} {insertLargeOp "bigwedge"}
  1053. proc bigOr {} {insertLargeOp "bigvee"}
  1054.  
  1055. # Arrows:
  1056. proc mapsTo {} {insertObject "\\mapsto"}
  1057. proc leftArrow {} {insertObject "\\leftarrow"}
  1058. proc rightArrow {} {insertObject "\\rightarrow"}
  1059. proc {left-rightArrow} {} {insertObject "\\leftrightarrow"}
  1060. proc dblLeftArrow {} {insertObject "\\Leftarrow"}
  1061. proc dblRightArrow {} {insertObject "\\Rightarrow"}
  1062. proc {dblLeft-rightArrow} {} {insertObject "\\Leftrightarrow"}
  1063.  
  1064. # Dots:
  1065. proc centerDots {} {insertObject "\\cdots"}
  1066. proc verticalDots {} {insertObject "\\vdots"}
  1067. proc diagonalDots {} {insertObject "\\ddots"}
  1068.  
  1069. # Symbols:
  1070. proc aleph {} {insertObject "\\aleph"}
  1071. proc emptySet {} {insertObject "\\emptyset"}
  1072. proc negation {} {insertObject "\\neg"}
  1073. proc forAll {} {insertObject "\\forall"}
  1074. proc exists {} {insertObject "\\exists"}
  1075. proc scriptL {} {insertObject "\\ell"}
  1076. proc nabla {} {insertObject "\\nabla"}
  1077. proc partial {} {insertObject "\\partial"}
  1078. proc infinity {} {insertObject "\\infty"}
  1079. proc backslash {} {insertObject "\\backslash"}
  1080. proc angle {} {insertObject "\\angle"}
  1081. proc box {} {insertObject "\\Box"}
  1082. proc diamond {} {insertObject "\\Diamond"}
  1083. proc triangle {} {insertObject "\\triangle"}
  1084.  
  1085. # Functions:  not yet implemented.
  1086.  
  1087. # Delimiters:
  1088. proc parentheses {} {
  1089.     if {[wrapObject "(" ")•"]} then {
  1090.         message "formula delimited"
  1091.     } else {
  1092.         message "enter formula"
  1093.     }
  1094. }
  1095. proc brackets {} {
  1096.     if {[wrapObject "\[" "\]•"]} then {
  1097.         message "formula delimited"
  1098.     } else {
  1099.         message "enter formula"
  1100.     }
  1101. }
  1102. proc braces {} {
  1103.     if {[wrapObject "\\\{" "\\\}•"]} then {
  1104.         message "formula delimited"
  1105.     } else {
  1106.         message "enter formula"
  1107.     }
  1108. }
  1109. proc absoluteValue {} {
  1110.     if {[wrapObject "|" "|•"]} then {
  1111.         message "formula delimited"
  1112.     } else {
  1113.         message "enter formula"
  1114.     }
  1115. }
  1116. proc otherDelims {} {
  1117.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" "braces" "angle brackets" "vertical bars" "double bars" "ceiling" "floor"} delimType
  1118.     if {$delimType != "cancel"} then {
  1119.         case $delimType in {
  1120.             "parentheses" {
  1121.                 set leftDelim "("
  1122.                 set rightDelim ")"
  1123.             }
  1124.             "brackets" {
  1125.                 set leftDelim "\["
  1126.                 set rightDelim "\]"
  1127.             }
  1128.             "braces" {
  1129.                 set leftDelim "\\\{"
  1130.                 set rightDelim "\\\}"
  1131.             }
  1132.             "{angle brackets}" {
  1133.                 set leftDelim "\\langle"
  1134.                 set rightDelim "\\rangle"
  1135.             }
  1136.             "{vertical bars}" {
  1137.                 set leftDelim "|"
  1138.                 set rightDelim "|"
  1139.             }
  1140.             "{double bars}" {
  1141.                 set leftDelim "\\|"
  1142.                 set rightDelim "\\|"
  1143.             }
  1144.             "ceiling" {
  1145.                 set leftDelim "\\lceil"
  1146.                 set rightDelim "\\rceil"
  1147.             }
  1148.             "floor" {
  1149.                 set leftDelim "\\lfloor"
  1150.                 set rightDelim "\\rfloor"
  1151.             }
  1152.             default {
  1153.                 alertnote "\"$delimType\" not recognized"
  1154.                 return
  1155.             }
  1156.         }
  1157.         if {[wrapObject "$leftDelim" "$rightDelim•"]} then {
  1158.             message "formula delimited"
  1159.         } else {
  1160.             message "enter formula"
  1161.         }
  1162.     }
  1163. }
  1164.  
  1165. proc {half-openInterval} {} {
  1166.     if {[wrapObject "(" "\]•"]} then {
  1167.         message "formula delimited"
  1168.     } else {
  1169.         message "enter formula"
  1170.     }
  1171. }
  1172. proc {half-closedInterval} {} {
  1173.     if {[wrapObject "\[" ")•"]} then {
  1174.         message "formula delimited"
  1175.     } else {
  1176.         message "enter formula"
  1177.     }
  1178. }
  1179.  
  1180. proc bigParentheses {} {
  1181.     if {[wrapObject "\\left(" "\\right)•"]} then {
  1182.         message "formula delimited"
  1183.     } else {
  1184.         message "enter formula"
  1185.     }
  1186. }
  1187. proc bigBrackets {} {
  1188.     if {[wrapObject "\\left\[" "\\right\]•"]} then {
  1189.         message "formula delimited"
  1190.     } else {
  1191.         message "enter formula"
  1192.     }
  1193. }
  1194. proc bigBraces {} {
  1195.     if {[wrapObject "\\left\\\{" "\\right\\\}•"]} then {
  1196.         message "formula delimited"
  1197.     } else {
  1198.         message "enter formula"
  1199.     }
  1200. }
  1201. proc bigAbsoluteValue {} {
  1202.     if {[wrapObject "\\left|" "\\right|•"]} then {
  1203.         message "formula delimited"
  1204.     } else {
  1205.         message "enter formula"
  1206.     }
  1207. }
  1208. proc otherBigDelims {} {
  1209.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" "brackets" \
  1210.                 "braces" "angle brackets" "vertical bars" "double bars" \
  1211.                 "ceiling" "floor"} delimType
  1212.     if {$delimType != "cancel"} then {
  1213.         case $delimType in {
  1214.             "parentheses" {
  1215.                 set leftDelim "("
  1216.                 set rightDelim ")"
  1217.             }
  1218.             "brackets" {
  1219.                 set leftDelim "\["
  1220.                 set rightDelim "\]"
  1221.             }
  1222.             "braces" {
  1223.                 set leftDelim "\\\{"
  1224.                 set rightDelim "\\\}"
  1225.             }
  1226.             "{angle brackets}" {
  1227.                 set leftDelim "\\langle"
  1228.                 set rightDelim "\\rangle"
  1229.             }
  1230.             "{vertical bars}" {
  1231.                 set leftDelim "|"
  1232.                 set rightDelim "|"
  1233.             }
  1234.             "{double bars}" {
  1235.                 set leftDelim "\\|"
  1236.                 set rightDelim "\\|"
  1237.             }
  1238.             "ceiling" {
  1239.                 set leftDelim "\\lceil"
  1240.                 set rightDelim "\\rceil"
  1241.             }
  1242.             "floor" {
  1243.                 set leftDelim "\\lfloor"
  1244.                 set rightDelim "\\rfloor"
  1245.             }
  1246.             default {
  1247.                 alertnote "\"$delimType\" not recognized"
  1248.                 return
  1249.             }
  1250.         }
  1251.         if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
  1252.             message "formula delimited"
  1253.         } else {
  1254.             message "enter formula"
  1255.         }
  1256.     }
  1257. }
  1258.  
  1259. proc bigLeftBrace {} {
  1260.     if {[wrapObject "\\left\\\{" "\\right.•"]} then {
  1261.         message "formula delimited"
  1262.     } else {
  1263.         message "enter formula"
  1264.     }
  1265. }
  1266. proc otherMixedBigDelims {} {
  1267.     catch {prompt "Choose left delimiter:" "parenthesis" "" "parenthesis" "bracket" \
  1268.              "brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor"  \
  1269.              "slash" "backslash" "none"} delimType
  1270.     if {$delimType != "cancel"} then {
  1271.         case $delimType in {
  1272.             "parenthesis" {set leftDelim "("}
  1273.             "bracket" {set leftDelim "\["}
  1274.             "brace" {set leftDelim "\\\{"}
  1275.             "{angle bracket}" {set leftDelim "\\langle"}
  1276.             "{vertical bar}" {set leftDelim "|"}
  1277.             "{double bar}" {set leftDelim "\\|"}
  1278.             "ceiling" {set leftDelim "\\lceil"}
  1279.             "floor" {set leftDelim "\\lfloor"}
  1280.             "slash" {set leftDelim "/"}
  1281.             "backslash" {set leftDelim "\\backslash"}
  1282.             "none" {set leftDelim "."}
  1283.             default {
  1284.                 alertnote "\"$delimType\" not recognized"
  1285.                 return
  1286.             }
  1287.         }
  1288.         catch {prompt "Choose right delimiter:" "parenthesis" "" "parenthesis" "bracket" \
  1289.                 "brace" "angle bracket" "vertical bar" "double bar" "ceiling" "floor" \
  1290.                 "slash" "backslash" "none"} delimType
  1291.         if {$delimType != "cancel"} then {
  1292.             case $delimType in {
  1293.                 "parenthesis" {set rightDelim ")"}
  1294.                 "bracket" {set rightDelim "\]"}
  1295.                 "brace" {set rightDelim "\\\}"}
  1296.                 "{angle bracket}" {set rightDelim "\\rangle"}
  1297.                 "{vertical bar}" {set rightDelim "|"}
  1298.                 "{double bar}" {set rightDelim "\\|"}
  1299.                 "ceiling" {set rightDelim "\\rceil"}
  1300.                 "floor" {set rightDelim "\\rfloor"}
  1301.                 "slash" {set rightDelim "/"}
  1302.                 "backslash" {set rightDelim "\\backslash"}
  1303.                 "none" {set rightDelim "."}
  1304.                 default {
  1305.                     alertnote "\"$delimType\" not recognized"
  1306.                     return
  1307.                 }
  1308.             }
  1309.             if {[wrapObject "\\left$leftDelim" "\\right$rightDelim•"]} then {
  1310.                 message "formula delimited"
  1311.             } else {
  1312.                 message "enter formula"
  1313.             }
  1314.         }
  1315.     }
  1316. }
  1317.  
  1318. # Accents:
  1319. proc hat {} {
  1320.     if {[isSelection] > 1} then {
  1321.         beep
  1322.         alertnote "Warning: only a single character may be accented!"
  1323.     }
  1324.     if {[wrapObject "\\hat{" "}•"]} then {
  1325.         message "accent set"
  1326.     } else {
  1327.         message "enter one character"
  1328.     }
  1329. }
  1330. proc check {} {
  1331.     if {[isSelection] > 1} then {
  1332.         beep
  1333.         alertnote "Warning: only a single character may be accented!"
  1334.     }
  1335.     if {[wrapObject "\\check{" "}•"]} then {
  1336.         message "accent set"
  1337.     } else {
  1338.         message "enter one character"
  1339.     }
  1340. }
  1341. proc breve {} {
  1342.     if {[isSelection] > 1} then {
  1343.         beep
  1344.         alertnote "Warning: only a single character may be accented!"
  1345.     }
  1346.     if {[wrapObject "\\breve{" "}•"]} then {
  1347.         message "accent set"
  1348.     } else {
  1349.         message "enter one character"
  1350.     }
  1351. }
  1352. proc acuteAccent {} {
  1353.     if {[isSelection] > 1} then {
  1354.         beep
  1355.         alertnote "Warning: only a single character may be accented!"
  1356.     }
  1357.     if {[wrapObject "\\acute{" "}•"]} then {
  1358.         message "accent set"
  1359.     } else {
  1360.         message "enter one character"
  1361.     }
  1362. }
  1363. proc graveAccent {} {
  1364.     if {[isSelection] > 1} then {
  1365.         beep
  1366.         alertnote "Warning: only a single character may be accented!"
  1367.     }
  1368.     if {[wrapObject "\\grave{" "}•"]} then {
  1369.         message "accent set"
  1370.     } else {
  1371.         message "enter one character"
  1372.     }
  1373. }
  1374. proc tilde {} {
  1375.     if {[isSelection] > 1} then {
  1376.         beep
  1377.         alertnote "Warning: only a single character may be accented!"
  1378.     }
  1379.     if {[wrapObject "\\tilde{" "}•"]} then {
  1380.         message "accent set"
  1381.     } else {
  1382.         message "enter one character"
  1383.     }
  1384. }
  1385. proc bar {} {
  1386.     if {[isSelection] > 1} then {
  1387.         beep
  1388.         alertnote "Warning: only a single character may be accented!"
  1389.     }
  1390.     if {[wrapObject "\\bar{" "}•"]} then {
  1391.         message "accent set"
  1392.     } else {
  1393.         message "enter one character"
  1394.     }
  1395. }
  1396. proc vector {} {
  1397.     if {[isSelection] > 1} then {
  1398.         beep
  1399.         alertnote "Warning: only a single character may be accented!"
  1400.     }
  1401.     if {[wrapObject "\\vec{" "}•"]} then {
  1402.         message "accent set"
  1403.     } else {
  1404.         message "enter one character"
  1405.     }
  1406. }
  1407. proc dot {} {
  1408.     if {[isSelection] > 1} then {
  1409.         beep
  1410.         alertnote "Warning: only a single character may be accented!"
  1411.     }
  1412.     if {[wrapObject "\\dot{" "}•"]} then {
  1413.         message "accent set"
  1414.     } else {
  1415.         message "enter one character"
  1416.     }
  1417. }
  1418. proc dblDot {} {
  1419.     if {[isSelection] > 1} then {
  1420.         beep
  1421.         alertnote "Warning: only a single character may be accented!"
  1422.     }
  1423.     if {[wrapObject "\\ddot{" "}•"]} then {
  1424.         message "accent set"
  1425.     } else {
  1426.         message "enter one character"
  1427.     }
  1428. }
  1429.  
  1430. proc wideHat {} {
  1431.     if {[isSelection] > 3} then {
  1432.         beep
  1433.         alertnote "Warning: only a few characters may be accented!"
  1434.     }
  1435.     if {[wrapObject "\\widehat{" "}•"]} then {
  1436.         message "accent set"
  1437.     } else {
  1438.         message "enter a few characters"
  1439.     }
  1440. }
  1441. proc wideTilde {} {
  1442.     if {[isSelection] > 3} then {
  1443.         beep
  1444.         alertnote "Warning: only a few characters may be accented!"
  1445.     }
  1446.     if {[wrapObject "\\widetilde{" "}•"]} then {
  1447.         message "accent set"
  1448.     } else {
  1449.         message "enter a few characters"
  1450.     }
  1451. }
  1452.  
  1453. proc dotlessI {} {insertObject "\\imath"}
  1454. proc dotlessJ {} {insertObject "\\jmath"}
  1455.  
  1456. # Grouping:
  1457. proc underline {} {
  1458.     if {[wrapObject "\\underline{" "}•"]} then {
  1459.         message "selection underlined"
  1460.     } else {
  1461.         message "enter text"
  1462.     }
  1463. }
  1464. proc overline {} {
  1465.     if {[wrapObject "\\overline{" "}•"]} then {
  1466.         message "selection overlined"
  1467.     } else {
  1468.         message "enter text"
  1469.     }
  1470. }
  1471. proc underbrace {} {
  1472.     if {[wrapObject "\\underbrace{" "}•"]} then {
  1473.         message "selection underbraced"
  1474.     } else {
  1475.         message "enter text"
  1476.     }
  1477. }
  1478. proc overbrace {} {
  1479.     if {[wrapObject "\\overbrace{" "}•"]} then {
  1480.         message "selection overbraced"
  1481.     } else {
  1482.         message "enter text"
  1483.     }
  1484. }
  1485. proc stack {} {
  1486.     set currentPos [getPos]
  1487.     if {[insertObject "\\stackrel{•}{•}•"]} then {
  1488.         goto $currentPos
  1489.         nextTabStop
  1490.         message "1st arg scriptstyle"
  1491.     }
  1492. }
  1493.  
  1494. # Spacing:
  1495. proc thin {} {insertObject "\\,"}
  1496. proc negThin {} {insertObject "\\!"}
  1497. proc medium {} {insertObject "\\:"}
  1498. proc thick {} {insertObject "\\;"}
  1499. proc quad {} {insertObject "\\quad"}
  1500. proc dblQuad {} {insertObject "\\qquad"}
  1501.  
  1502. # Math Style:
  1503. proc mathItalic {} {
  1504.     if {[wrapObject "{\\mit " "}•"]} then {
  1505.         message "math italics set"
  1506.     } else {
  1507.         message "enter italicized text"
  1508.     }
  1509. }
  1510. proc calligraphic {} {
  1511.     # Check for upper-case arguments only:
  1512.     if {[wrapObject "{\\cal " "}•"]} then {
  1513.         message "calligraphics set"
  1514.     } else {
  1515.         message "enter text"
  1516.     }
  1517. }
  1518. proc fraktur {} {
  1519.     alertnote "Not yet implemented."
  1520. }
  1521. proc script {} {
  1522.     alertnote "Not yet implemented."
  1523. }
  1524. proc blackboardBold {} {
  1525.     alertnote "Not yet implemented."
  1526. }
  1527. proc displayStyle {} {
  1528.     if {[wrapObject "{\\displaystyle " "}•"]} then {
  1529.         message "displaystyle set"
  1530.     } else {
  1531.         message "enter displaystyle text"
  1532.     }
  1533. }
  1534. proc textStyle {} {
  1535.     if {[wrapObject "{\\textstyle " "}•"]} then {
  1536.         message "textstyle set"
  1537.     } else {
  1538.         message "enter textstyle text"
  1539.     }
  1540. }
  1541. proc scriptStyle {} {
  1542.     if {[wrapObject "{\\scriptstyle " "}•"]} then {
  1543.         message "scriptstyle set"
  1544.     } else {
  1545.         message "enter scriptstyle text"
  1546.     }
  1547. }
  1548. proc scriptscriptStyle {} {
  1549.     if {[wrapObject "{\\scriptscriptstyle " "}•"]} then {
  1550.         message "scriptscriptstyle set"
  1551.     } else {
  1552.         message "enter scriptscriptstyle text"
  1553.     }
  1554. }
  1555.  
  1556.  
  1557. #############################################################################
  1558. #
  1559. # LaTeX Menu Definition.
  1560. #
  1561. #############################################################################
  1562.  
  1563. proc interpretMenuItem {menu item} {
  1564.     switch $item {
  1565.         "list" {set func "myList"}
  1566.         "array" {set func "myArray"}
  1567.         "eqnarray\*" {set func "eqnarrayStar"}
  1568.         default {set func $item}
  1569.     }
  1570.     eval $func
  1571. }
  1572.  
  1573.  
  1574. #================================================================================
  1575. proc latex {} {
  1576.     global latexPath
  1577.     set sig ""
  1578.     set name [checkRunning LaTeX {OTEX *TEX *XeT MPS* TeX+} latexPath]
  1579.     if {![string length $name]} return
  1580.     switchTo $name
  1581. }
  1582.  
  1583. proc commentLine {} {
  1584.     beginningOfLine
  1585.     insertText "% "
  1586.     nextLine
  1587.     beginningOfLine
  1588. }
  1589.  
  1590.  
  1591. proc TeXMarkFile {} {
  1592.     set end [maxPos]
  1593.     set pos 0
  1594.     set l {}
  1595.  
  1596.     # Remove all previous marks in this file?
  1597.     set exp {\\((sub)*section|chapter)(\[.*\]|\*)?{([^{}]*)}}
  1598.     while {![catch {search -f 1 -r 1 -m 0 -i 0 $exp $pos} res]} {
  1599.         set start [lindex $res 0]
  1600.         set end [lindex $res 1]
  1601.         set text [getText $start $end]
  1602.         if {[regexp {\{(.*)\}} $text dummy mtch]} {
  1603.             set lab ""
  1604.             if {[regexp {(sub)*section} $text title]} then {
  1605.                 append lab $l [format "%[expr [string length $title] - 7]\s" ""]
  1606.             } else {
  1607.                 set l {   }
  1608.             }
  1609.             append lab $mtch
  1610.             setNamedMark $lab [lineStart [expr $start - 1]] $start $start
  1611.         }
  1612.         set pos [expr $end+1]
  1613.     }
  1614. }
  1615.  
  1616.     
  1617. # Open file in same directory, expect name w/o extension selected.
  1618. proc openInputFile {} {
  1619.     set text [getSelect].tex
  1620.     if {[string length $text] < 5} { beep; return }
  1621.     foreach f [winNames] {
  1622.         if {$f == $text} {
  1623.             bringToFront $f
  1624.             return
  1625.         }
  1626.     }
  1627.     edit [file dirname [lindex [winNames -f] 0]]:$text
  1628. }
  1629.  
  1630.  
  1631. menu -n $latexMenu  {
  1632.     "/-latex"
  1633.     "openInputFile"
  1634.     "(-"
  1635.     {menu -n Documents -p interpretMenuItem {
  1636.         "letter"
  1637.         "article"
  1638.         "report"
  1639.         "book"
  1640.         "(-"
  1641.         "custom…"}
  1642.     }
  1643.     
  1644.     {menu -n Sectioning -p interpretMenuItem {
  1645.         "part"
  1646.         "chapter"
  1647.         "section"
  1648.         "subsection"
  1649.         "subsubsection"
  1650.         "paragraph"
  1651.         "subparagraph"}
  1652.     }
  1653.     
  1654.     {menu -n (Definitions -p interpretMenuItem {
  1655.         "list…"
  1656.         "(-"
  1657.         "newcommand…"
  1658.         "newenvironment…"
  1659.         "newtheorem…"
  1660.         "(-"
  1661.         "renewcommand…"
  1662.         "renewenvironment…"}
  1663.     }
  1664.     
  1665.     "(-"
  1666.     
  1667.     {menu -n TextStyle -p interpretMenuItem {
  1668.         "roman"
  1669.         "bold"
  1670.         "italic"
  1671.         "emphatic"
  1672.         "slanted"
  1673.         "sansSerif"
  1674.         "smallCaps"
  1675.         "typewriter"}
  1676.     }
  1677.     
  1678.     {menu -n TextSize -p interpretMenuItem {
  1679.         "tiny"
  1680.         "smallest"
  1681.         "smaller"
  1682.         "small"
  1683.         "normal"
  1684.         "large"
  1685.         "larger"
  1686.         "largest"
  1687.         "huge"
  1688.         "gigantic"}
  1689.     }
  1690.     
  1691.     {menu -n (International -p interpretMenuItem {
  1692.         }
  1693.     }
  1694.     
  1695.     {menu -n Environments -p interpretMenuItem {
  1696.         "enumerate…"
  1697.         "itemize…"
  1698.         "description…"
  1699.         "(-"
  1700.         "tabular…"
  1701.         "(tabbing"
  1702.         "(-"
  1703.         "figure"
  1704.         "table"
  1705.         "slide"
  1706.         "(-"
  1707.         "verbatim"
  1708.         "quote"
  1709.         "quotation"
  1710.         "verse"
  1711.         "(-"
  1712.         "(index…"
  1713.         "bibliography…"
  1714.         "(-"
  1715.         "general…"}
  1716.     }
  1717.     
  1718.     {menu -n Boxes -p interpretMenuItem {
  1719.         "mbox"
  1720.         "(fbox"
  1721.         "(parbox"}
  1722.     }
  1723.     
  1724.     {menu -n Miscellaneous -p interpretMenuItem {
  1725.         "ellipsis"
  1726.         "sectionMark"
  1727.         "paragraphMark"
  1728.         "dagger"
  1729.         "dblDagger"
  1730.         "en-dash"
  1731.         "em-dash"
  1732.         "texLogo"
  1733.         "latexLogo"
  1734.         "copyright"
  1735.         "pounds"
  1736.         "today"
  1737.         "(-"
  1738.         "quotes"
  1739.         "dblQuotes"
  1740.         "(-"
  1741.         "note"
  1742.         "footnote"
  1743.         "(-"
  1744.         "label"
  1745.         "crossRef"
  1746.         "pageRef"
  1747.         "citation"
  1748.         "(-"
  1749.         "item"
  1750.         "bibitem"
  1751.         }
  1752.     }
  1753.     
  1754.     "(-"
  1755.     
  1756.     {menu -n mathModes -p interpretMenuItem {
  1757.         "texMath"
  1758.         "texDisplaymath"
  1759.         "(-"
  1760.         "latexMath"
  1761.         "latexDisplaymath"}
  1762.     }
  1763.     
  1764.     {menu -n mathEnvironments -p interpretMenuItem {
  1765.         "math"
  1766.         "displaymath"
  1767.         "equation"
  1768.         "(-"
  1769.         "array…"
  1770.         "eqnarray…"
  1771.         "eqnarray*…"
  1772.         "(-"
  1773.         "general…"}
  1774.     }
  1775.     
  1776.     {menu -n Formulas -p interpretMenuItem {
  1777.         "subscript"
  1778.         "superscript"
  1779.         "fraction"
  1780.         "squareRoot"
  1781.         "nthRoot"
  1782.         "(-"
  1783.         "oneParameter…"
  1784.         "twoParameters…"
  1785.         }
  1786.     }
  1787.     
  1788.     {menu -n Greek -p interpretMenuItem {
  1789.         "alpha"
  1790.         "beta"
  1791.         "gamma"
  1792.         "delta"
  1793.         "epsilon"
  1794.         "zeta"
  1795.         "eta"
  1796.         "theta"
  1797.         "iota"
  1798.         "kappa"
  1799.         "lambda"
  1800.         "mu"
  1801.         "nu"
  1802.         "xi"
  1803.         "pi"
  1804.         "rho"
  1805.         "sigma"
  1806.         "tau"
  1807.         "upsilon"
  1808.         "phi"
  1809.         "chi"
  1810.         "psi"
  1811.         "omega"
  1812.         }
  1813.     }
  1814.     {menu -n Greek2 -p interpretMenuItem {
  1815.         "capGamma"
  1816.         "capDelta"
  1817.         "capTheta"
  1818.         "capLambda"
  1819.         "capXi"
  1820.         "capPi"
  1821.         "capSigma"
  1822.         "capUpsilon"
  1823.         "capPhi"
  1824.         "capPsi"
  1825.         "capOmega"
  1826.         "(-"
  1827.         "varEpsilon"
  1828.         "varTheta"
  1829.         "varPi"
  1830.         "varRho"
  1831.         "varSigma"
  1832.         "varPhi"
  1833.         }
  1834.     }
  1835.         
  1836.     {menu -n BinaryOperators -p interpretMenuItem {
  1837.         "plusOrMinus"
  1838.         "minusOrPlus"
  1839.         "multiply"
  1840.         "divide"
  1841.         "asterisk"
  1842.         "star"
  1843.         "centerDot"
  1844.         "bullet"
  1845.         "circle"
  1846.         "bigCircle"
  1847.         "intersection"
  1848.         "union"
  1849.         "logicalAnd"
  1850.         "logicalOr"
  1851.         "setMinus"
  1852.         }
  1853.     }
  1854.     
  1855.     {menu -n Relations -p interpretMenuItem {
  1856.         "notEqual"
  1857.         "lessOrEqual"
  1858.         "greaterOrEqual"
  1859.         "subset"
  1860.         "superset"
  1861.         "subsetOrEqual"
  1862.         "supersetOrEqual"
  1863.         "elementOf"
  1864.         "equivalent"
  1865.         "similar"
  1866.         "similarEqual"
  1867.         "dotEqual"
  1868.         "approximate"
  1869.         "congruent"
  1870.         }
  1871.     }
  1872.     
  1873.     {menu -n LargeOperators -p interpretMenuItem {
  1874.         "sum"
  1875.         "product"
  1876.         "integral"
  1877.         "bigUnion"
  1878.         "bigIntersection"
  1879.         "bigAnd"
  1880.         "bigOr"
  1881.         }
  1882.     }
  1883.     
  1884.     {menu -n Arrows -p interpretMenuItem {
  1885.         "mapsTo"
  1886.         "leftArrow"
  1887.         "rightArrow"
  1888.         "left-rightArrow"
  1889.         "dblLeftArrow"
  1890.         "dblRightArrow"
  1891.         "dblLeft-rightArrow"
  1892.         }
  1893.     }
  1894.     
  1895.     {menu -n Dots -p interpretMenuItem {
  1896.         "centerDot"
  1897.         "bullet"
  1898.         "(-"
  1899.         "ellipsis"
  1900.         "centerDots"
  1901.         "verticalDots"
  1902.         "diagonalDots"
  1903.         }
  1904.     }
  1905.     
  1906.     {menu -n Symbols -p interpretMenuItem {
  1907.         "aleph"
  1908.         "emptySet"
  1909.         "negation"
  1910.         "forAll"
  1911.         "exists"
  1912.         "scriptL"
  1913.         "nabla"
  1914.         "partial"
  1915.         "infinity"
  1916.         "backslash"
  1917.         "angle"
  1918.         "box"
  1919.         "diamond"
  1920.         "triangle"
  1921.         }
  1922.     }
  1923.         
  1924.     {menu -n (Functions -p interpretMenuItem {
  1925.         }
  1926.     }
  1927.  
  1928.     {menu -n Delimiters -p interpretMenuItem {
  1929.         "parentheses"
  1930.         "brackets"
  1931.         "braces"
  1932.         "absoluteValue"
  1933.         "otherDelims…"
  1934.         "(-"
  1935.         "half-openInterval"
  1936.         "half-closedInterval"
  1937.         "(-"
  1938.         "bigParentheses"
  1939.         "bigBrackets"
  1940.         "bigBraces"
  1941.         "bigAbsoluteValue"
  1942.         "otherBigDelims…"
  1943.         "(-"
  1944.         "bigLeftBrace"
  1945.         "otherMixedBigDelims…"
  1946.         }
  1947.     }
  1948.         
  1949.     {menu -n mathAccents -p interpretMenuItem {
  1950.         "hat"
  1951.         "check"
  1952.         "breve"
  1953.         "acuteAccent"
  1954.         "graveAccent"
  1955.         "tilde"
  1956.         "bar"
  1957.         "vector"
  1958.         "dot"
  1959.         "dblDot"
  1960.         "(-"
  1961.         "wideHat"
  1962.         "wideTilde"
  1963.         "(-"
  1964.         "dotlessI"
  1965.         "dotlessJ"
  1966.         }
  1967.     }
  1968.     
  1969.     {menu -n Grouping -p interpretMenuItem {
  1970.         "underline"
  1971.         "overline"
  1972.         "underbrace"
  1973.         "overbrace"
  1974.         "(-"
  1975.         "stack"
  1976.         }
  1977.     }
  1978.     
  1979.     {menu -n Spacing -p interpretMenuItem {
  1980.         "thin"
  1981.         "negThin"
  1982.         "medium"
  1983.         "thick"
  1984.         "(-"
  1985.         "quad"
  1986.         "dblQuad"
  1987.         }
  1988.     }
  1989.     
  1990.     {menu -n MathStyle -p interpretMenuItem {
  1991.         "mathItalic"
  1992.         "calligraphic"
  1993.         "(-"
  1994.         "(fraktur"
  1995.         "(script"
  1996.         "(blackboardBold"
  1997.         "(-"
  1998.         "displayStyle"
  1999.         "textStyle"
  2000.         "scriptStyle"
  2001.         "scriptscriptStyle"
  2002.         }
  2003.     }
  2004. }
  2005.  
  2006.  
  2007. #############################################################################
  2008. #
  2009. # Special Key Bindings.
  2010. #
  2011. # abbreviations:  <o> = option, <z> = control, <s> = shift, <c> = command
  2012. #
  2013. #############################################################################
  2014.  
  2015. bind 0x14 <z> commentLine TeX
  2016. if {$optionIsMeta == "0"} then {
  2017.  
  2018.     #  use option for macros, escape for meta
  2019.  
  2020.     bind    'a'    <o>    alpha    "TeX"
  2021.     bind    'a'    <os>    angle    "TeX"
  2022.     bind    'a'    <oz>    forAll    "TeX"
  2023.     bind    'a'    <co>    acuteAccent    "TeX"
  2024.     
  2025.     bind    'b'    <o>    beta    "TeX"
  2026.     bind    'b'    <oz>    box    "TeX"
  2027.     bind    'b'    <co>    bar    "TeX"
  2028.     bind    'b'    <cs>    bold    "TeX"
  2029.     
  2030.     bind    'c'    <o>    chi    "TeX"
  2031.     bind    'c'    <co>    check    "TeX"
  2032.     bind    'c'    <cs>    citation    "TeX"
  2033.     bind    'c'    <cso>    calligraphic    "TeX"
  2034.     
  2035.     bind    'd'    <o>    delta    "TeX"
  2036.     bind    'd'    <os>    capDelta    "TeX"
  2037.     bind    'd'    <oz>    diamond    "TeX"
  2038.     bind    'd'    <co>    dot    "TeX"
  2039.     bind    'd'    <cso>    dblDot    "TeX"
  2040.     
  2041.     bind    'e'    <o>    epsilon    "TeX"
  2042.     bind    'e'    <os>    exists    "TeX"
  2043.     bind    'e'    <oz>    varEpsilon    "TeX"
  2044.     bind    'e'    <cs>    emphatic    "TeX"
  2045.     
  2046.     bind    'f'    <o>    phi    "TeX"
  2047.     bind    'f'    <os>    capPhi    "TeX"
  2048.     bind    'f'    <oz>    varPhi    "TeX"
  2049.     bind    'f'    <co>    fraction    "TeX"
  2050.     bind    'f'    <cs>    footnote    "TeX"
  2051.     
  2052.     bind    'g'    <o>    gamma    "TeX"
  2053.     bind    'g'    <os>    capGamma    "TeX"
  2054.     bind    'g'    <oz>    copyright    "TeX"
  2055.     bind    'g'    <co>    graveAccent    "TeX"
  2056.     
  2057.     bind    'h'    <o>    eta    "TeX"
  2058.     bind    'h'    <co>    hat    "TeX"
  2059.     bind    'h'    <cs>    smallCaps    "TeX"
  2060.     bind    'h'    <cso>    wideHat    "TeX"
  2061.     
  2062.     bind    'i'    <o>    iota    "TeX"
  2063.     bind    'i'    <oz>    dotlessI    "TeX"
  2064.     bind    'i'    <co>    integral    "TeX"
  2065.     bind    'i'    <cs>    italic    "TeX"
  2066.     bind    'i'    <cso>    mathItalic    "TeX"
  2067.     
  2068.     bind    'j'    <o>    partial    "TeX"
  2069.     bind    'j'    <oz>    dotlessJ    "TeX"
  2070.     
  2071.     bind    'k'    <o>    kappa    "TeX"
  2072.     
  2073.     bind    'l'    <o>    lambda    "TeX"
  2074.     bind    'l'    <os>    capLambda    "TeX"
  2075.     bind    'l'    <oz>    scriptL    "TeX"
  2076.     bind    'l'    <cs>    label    "TeX"
  2077.     
  2078.     bind    'm'    <o>    mu    "TeX"
  2079.     bind    'm'    <oz>    mapsTo    "TeX"
  2080.     bind    'm'    <co>    mbox    "TeX"
  2081.     bind    'm'    <cs>    mbox    "TeX"
  2082.     
  2083.     bind    'n'    <o>    nu    "TeX"
  2084.     bind    'n'    <os>    aleph    "TeX"
  2085.     bind    'n'    <oz>    intersection    "TeX"
  2086.     bind    'n'    <co>    nthRoot    "TeX"
  2087.     bind    'n'    <cs>    note    "TeX"
  2088.     
  2089.     bind    'o'    <o>    circle    "TeX"
  2090.     bind    'o'    <os>    bigCircle    "TeX"
  2091.     bind    'o'    <co>    overline    "TeX"
  2092.     bind    'o'    <cso>    overbrace    "TeX"
  2093.     
  2094.     bind    'p'    <o>    pi    "TeX"
  2095.     bind    'p'    <os>    capPi    "TeX"
  2096.     bind    'p'    <oz>    varPi    "TeX"
  2097.     bind    'p'    <co>    product    "TeX"
  2098.     bind    'p'    <cs>    pageRef    "TeX"
  2099.     
  2100.     bind    'q'    <o>    theta    "TeX"
  2101.     bind    'q'    <os>    capTheta    "TeX"
  2102.     bind    'q'    <oz>    varTheta    "TeX"
  2103.     
  2104.     bind    'r'    <o>    rho    "TeX"
  2105.     bind    'r'    <oz>    varRho    "TeX"
  2106.     bind    'r'    <co>    squareRoot    "TeX"
  2107.     bind    'r'    <cs>    roman    "TeX"
  2108.     
  2109.     bind    's'    <o>    sigma    "TeX"
  2110.     bind    's'    <os>    capSigma    "TeX"
  2111.     bind    's'    <oz>    varSigma    "TeX"
  2112.     bind    's'    <co>    sum    "TeX"
  2113.     bind    's'    <cs>    slanted    "TeX"
  2114.     
  2115.     bind    't'    <o>    tau    "TeX"
  2116.     bind    't'    <os>    dagger    "TeX"
  2117.     bind    't'    <oz>    triangle    "TeX"
  2118.     bind    't'    <co>    tilde    "TeX"
  2119.     bind    't'    <cs>    typewriter    "TeX"
  2120.     bind    't'    <cso>    wideTilde    "TeX"
  2121.     
  2122.     bind    'u'    <o>    upsilon    "TeX"
  2123.     bind    'u'    <os>    capUpsilon    "TeX"
  2124.     bind    'u'    <oz>    union    "TeX"
  2125.     bind    'u'    <co>    underline    "TeX"
  2126.     bind    'u'    <cso>    underbrace    "TeX"
  2127.     
  2128.     bind    'v'    <o>    nabla    "TeX"
  2129.     bind    'v'    <oz>    logicalOr    "TeX"
  2130.     bind    'v'    <co>    vector    "TeX"
  2131.     
  2132.     bind    'w'    <o>    omega    "TeX"
  2133.     bind    'w'    <os>    capOmega    "TeX"
  2134.     bind    'w'    <oz>    logicalAnd    "TeX"
  2135.     bind    'w'    <cs>    sansSerif    "TeX"
  2136.     
  2137.     bind    'x'    <o>    xi    "TeX"
  2138.     bind    'x'    <os>    capXi    "TeX"
  2139.     bind    'x'    <oz>    multiply    "TeX"
  2140.     bind    'x'    <cs>    crossRef    "TeX"
  2141.     
  2142.     bind    'y'    <o>    psi    "TeX"
  2143.     bind    'y'    <os>    capPsi    "TeX"
  2144.     
  2145.     bind    'z'    <o>    zeta    "TeX"
  2146.     
  2147.     bind    '\ '    <o>    thin    "TeX"
  2148.     bind    '\ '    <os>    negThin    "TeX"
  2149.     bind    '\ '    <oz>    medium    "TeX"
  2150.     bind    '\ '    <co>    thick    "TeX"
  2151.     bind    '\ '    <cs>    quad    "TeX"
  2152.     bind    '\ '    <cso>    dblQuad    "TeX"
  2153.     
  2154.     bind    ','    <o>    lessOrEqual    "TeX"
  2155.     bind    ','    <os>    subset    "TeX"
  2156.     bind    ','    <oz>    subsetOrEqual    "TeX"
  2157.     bind    ','    <co>    subscript    "TeX"
  2158.     
  2159.     bind    '.'    <o>    greaterOrEqual    "TeX"
  2160.     bind    '.'    <os>    superset    "TeX"
  2161.     bind    '.'    <oz>    supersetOrEqual    "TeX"
  2162.     bind    '.'    <co>    superscript    "TeX"
  2163.     
  2164.     bind    '/'    <o>    divide    "TeX"
  2165.     bind    '/'    <co>    fraction    "TeX"
  2166.     
  2167.     bind    '\;'    <o>    ellipsis    "TeX"
  2168.     bind    '\;'    <os>    centerDots    "TeX"
  2169.     bind    '\;'    <oz>    verticalDots    "TeX"
  2170.     bind    '\;'    <co>    diagonalDots    "TeX"
  2171.     
  2172.     # apostrophe:
  2173.     bind    0x27    <co>    acuteAccent    "TeX"
  2174.     bind    0x27    <cs>    quotes    "TeX"
  2175.     bind    0x27    <cso>    dblQuotes    "TeX"
  2176.  
  2177.     bind    '\['    <o>    brackets    "TeX"
  2178.     bind    '\['    <os>    braces    "TeX"
  2179.     bind    '\['    <co>    bigBrackets    "TeX"
  2180.     bind    '\['    <cso>    bigBraces    "TeX"
  2181.  
  2182.     bind    '\]'    <o>    displayStyle    "TeX"
  2183.     bind    '\]'    <os>    textStyle    "TeX"
  2184.     bind    '\]'    <oz>    scriptStyle    "TeX"
  2185.     bind    '\]'    <co>    scriptscriptStyle    "TeX"
  2186.     bind    '\]'    <cso>    bigLeftBrace    "TeX"
  2187.     
  2188.     bind    '\'    <o>    backslash    "TeX"
  2189.     bind    '\'    <os>    absoluteValue    "TeX"
  2190.     bind    '\'    <oz>    setMinus    "TeX"
  2191.     bind    '\'    <co>    bigAbsoluteValue    "TeX"
  2192.     bind    '\'    <cs>    "oneParameter"    "TeX"
  2193.     bind    '\'    <cso>    "twoParameters"    "TeX"
  2194.     
  2195.     bind    '`'    <co>    graveAccent    "TeX"
  2196.     bind    '`'    <cso>    tilde    "TeX"
  2197.         
  2198.     # Change to latexMath and latexDisplaymath, if desired:
  2199.     bind    '4'    <co>    texMath    "TeX"
  2200.     bind    '4'    <cso>    texDisplaymath    "TeX"
  2201.     
  2202.     bind    '5'    <o>    infinity    "TeX"
  2203.     
  2204.     bind    '6'    <o>    sectionMark    "TeX"
  2205.     bind    '6'    <co>    superscript    "TeX"
  2206.     
  2207.     bind    '7'    <o>    paragraphMark    "TeX"
  2208.     
  2209.     bind    '8'    <o>    bullet    "TeX"
  2210.     bind    '8'    <os>    asterisk    "TeX"
  2211.     bind    '8'    <oz>    centerDot    "TeX"
  2212.     
  2213.     bind    '9'    <os>    parentheses    "TeX"
  2214.     bind    '9'    <co>    bigParentheses    "TeX"
  2215.     
  2216.     bind    '0'    <oz>    emptySet    "TeX"
  2217.     
  2218.     bind    '-'    <o>    similar    "TeX"
  2219.     bind    '-'    <os>    minusOrPlus    "TeX"
  2220.     bind    '-'    <oz>    negation    "TeX"
  2221.     bind    '-'    <co>    subscript    "TeX"
  2222.     
  2223.     bind    '='    <o>    notEqual    "TeX"
  2224.     bind    '='    <os>    plusOrMinus    "TeX"
  2225.     bind    '='    <oz>    approximate    "TeX"
  2226.     bind    '='    <co>    bar    "TeX"
  2227.     
  2228.     bind    F5    <o>    math    "TeX"
  2229.     bind    F5    <os>    displaymath    "TeX"
  2230.     bind    F5    <oz>    equation    "TeX"
  2231.     
  2232.     bind    F6    <o>    "myArray"    "TeX"
  2233.     bind    F6    <os>    "eqnarray"    "TeX"
  2234.     bind    F6    <oz>    "eqnarrayStar"    "TeX"
  2235.     
  2236.     bind    F7    <o>    "enumerate"    "TeX"
  2237.     bind    F7    <os>    "itemize"    "TeX"
  2238.     bind    F7    <oz>    "description"    "TeX"
  2239.     
  2240.     bind    F8    <o>    "tabular"    "TeX"
  2241.     bind    F8    <os>    tabbing    "TeX"
  2242.     
  2243.     bind    F9    <o>    figure    "TeX"
  2244.     bind    F9    <os>    table    "TeX"
  2245.     bind    F9    <oz>    slide    "TeX"
  2246.     
  2247.     bind    F10    <o>    verbatim    "TeX"
  2248.     bind    F10    <os>    quote    "TeX"
  2249.     bind    F10    <oz>    quotation    "TeX"
  2250.     bind    F10    <co>    verse    "TeX"
  2251.     
  2252.     bind    F11    <o>    "index"    "TeX"
  2253.     bind    F11    <os>    "bibliography"    "TeX"
  2254.     
  2255.     bind    F12    <o>    "general"    "TeX"
  2256.     
  2257.     # tab:
  2258.     bind    0x30    nextTabStop    "TeX"
  2259.     bind    0x30    <s>     previousTabStop    "TeX"
  2260.     
  2261. } else {
  2262.     
  2263.     #    bind    macros    to    option-control,    use    option    as    meta
  2264.     
  2265.     bind    'a'    <zo>    alpha    "TeX"
  2266.     bind    'a'    <zos>    angle    "TeX"
  2267.     # bind    'a'    <oz>    forAll    "TeX"
  2268.     bind    'a'    <zco>    acuteAccent    "TeX"
  2269.     
  2270.     bind    'b'    <zo>    beta    "TeX"
  2271.     # bind    'b'    <oz>    box    "TeX"
  2272.     bind    'b'    <zco>    bar    "TeX"
  2273.     bind    'b'    <zcs>    bold    "TeX"
  2274.     
  2275.     bind    'c'    <zo>    chi    "TeX"
  2276.     bind    'c'    <zco>    check    "TeX"
  2277.     bind    'c'    <zcs>    citation    "TeX"
  2278.     bind    'c'    <zcso>    calligraphic    "TeX"
  2279.     
  2280.     bind    'd'    <zo>    delta    "TeX"
  2281.     bind    'd'    <zos>    capDelta    "TeX"
  2282.     # bind    'd'    <oz>    diamond    "TeX"
  2283.     bind    'd'    <zco>    dot    "TeX"
  2284.     bind    'd'    <zcso>    dblDot    "TeX"
  2285.     
  2286.     bind    'e'    <zo>    epsilon    "TeX"
  2287.     bind    'e'    <zos>    exists    "TeX"
  2288.     # bind    'e'    <oz>    varEpsilon    "TeX"
  2289.     bind    'e'    <zcs>    emphatic    "TeX"
  2290.     
  2291.     bind    'f'    <zo>    phi    "TeX"
  2292.     bind    'f'    <zos>    capPhi    "TeX"
  2293.     # bind    'f'    <oz>    varPhi    "TeX"
  2294.     bind    'f'    <zco>    fraction    "TeX"
  2295.     bind    'f'    <zcs>    footnote    "TeX"
  2296.     
  2297.     bind    'g'    <zo>    gamma    "TeX"
  2298.     bind    'g'    <zos>    capGamma    "TeX"
  2299.     # bind    'g'    <oz>    copyright    "TeX"
  2300.     bind    'g'    <zco>    graveAccent    "TeX"
  2301.     
  2302.     bind    'h'    <zo>    eta    "TeX"
  2303.     bind    'h'    <zco>    hat    "TeX"
  2304.     bind    'h'    <zcs>    smallCaps    "TeX"
  2305.     bind    'h'    <zcso>    wideHat    "TeX"
  2306.     
  2307.     bind    'i'    <zo>    iota    "TeX"
  2308.     # bind    'i'    <oz>    dotlessI    "TeX"
  2309.     bind    'i'    <zco>    integral    "TeX"
  2310.     bind    'i'    <zcs>    italic    "TeX"
  2311.     bind    'i'    <zcso>    mathItalic    "TeX"
  2312.     
  2313.     bind    'j'    <zo>    partial    "TeX"
  2314.     # bind    'j'    <oz>    dotlessJ    "TeX"
  2315.     
  2316.     bind    'k'    <zo>    kappa    "TeX"
  2317.     
  2318.     bind    'l'    <zo>    lambda    "TeX"
  2319.     bind    'l'    <zos>    capLambda    "TeX"
  2320.     # bind    'l'    <oz>    scriptL    "TeX"
  2321.     bind    'l'    <zcs>    label    "TeX"
  2322.     
  2323.     bind    'm'    <zo>    mu    "TeX"
  2324.     # bind    'm'    <oz>    mapsTo    "TeX"
  2325.     bind    'm'    <zco>    mbox    "TeX"
  2326.     bind    'm'    <zcs>    mbox    "TeX"
  2327.     
  2328.     bind    'n'    <zo>    nu    "TeX"
  2329.     bind    'n'    <zos>    aleph    "TeX"
  2330.     # bind    'n'    <oz>    intersection    "TeX"
  2331.     bind    'n'    <zco>    nthRoot    "TeX"
  2332.     bind    'n'    <zcs>    note    "TeX"
  2333.     
  2334.     bind    'o'    <zo>    circle    "TeX"
  2335.     bind    'o'    <zos>    bigCircle    "TeX"
  2336.     bind    'o'    <zco>    overline    "TeX"
  2337.     bind    'o'    <zcso>    overbrace    "TeX"
  2338.     
  2339.     bind    'p'    <zo>    pi    "TeX"
  2340.     bind    'p'    <zos>    capPi    "TeX"
  2341.     # bind    'p'    <oz>    varPi    "TeX"
  2342.     bind    'p'    <zco>    product    "TeX"
  2343.     bind    'p'    <zcs>    pageRef    "TeX"
  2344.     
  2345.     bind    'q'    <zo>    theta    "TeX"
  2346.     bind    'q'    <zos>    capTheta    "TeX"
  2347.     # bind    'q'    <oz>    varTheta    "TeX"
  2348.     
  2349.     bind    'r'    <zo>    rho    "TeX"
  2350.     # bind    'r'    <oz>    varRho    "TeX"
  2351.     bind    'r'    <zco>    squareRoot    "TeX"
  2352.     bind    'r'    <zcs>    roman    "TeX"
  2353.     
  2354.     bind    's'    <zo>    sigma    "TeX"
  2355.     bind    's'    <zos>    capSigma    "TeX"
  2356.     # bind    's'    <oz>    varSigma    "TeX"
  2357.     bind    's'    <zco>    sum    "TeX"
  2358.     bind    's'    <zcs>    slanted    "TeX"
  2359.     
  2360.     bind    't'    <zo>    tau    "TeX"
  2361.     bind    't'    <zos>    dagger    "TeX"
  2362.     # bind    't'    <oz>    triangle    "TeX"
  2363.     bind    't'    <zco>    tilde    "TeX"
  2364.     bind    't'    <zcs>    typewriter    "TeX"
  2365.     bind    't'    <zcso>    wideTilde    "TeX"
  2366.     
  2367.     bind    'u'    <zo>    upsilon    "TeX"
  2368.     bind    'u'    <zos>    capUpsilon    "TeX"
  2369.     # bind    'u'    <oz>    union    "TeX"
  2370.     bind    'u'    <zco>    underline    "TeX"
  2371.     bind    'u'    <zcso>    underbrace    "TeX"
  2372.     
  2373.     bind    'v'    <zo>    nabla    "TeX"
  2374.     # bind    'v'    <oz>    logicalOr    "TeX"
  2375.     bind    'v'    <zco>    vector    "TeX"
  2376.     
  2377.     bind    'w'    <zo>    omega    "TeX"
  2378.     bind    'w'    <zos>    capOmega    "TeX"
  2379.     # bind    'w'    <oz>    logicalAnd    "TeX"
  2380.     bind    'w'    <zcs>    sansSerif    "TeX"
  2381.     
  2382.     bind    'x'    <zo>    xi    "TeX"
  2383.     bind    'x'    <zos>    capXi    "TeX"
  2384.     # bind    'x'    <oz>    multiply    "TeX"
  2385.     bind    'x'    <zcs>    crossRef    "TeX"
  2386.     
  2387.     bind    'y'    <zo>    psi    "TeX"
  2388.     bind    'y'    <zos>    capPsi    "TeX"
  2389.     
  2390.     bind    'z'    <zo>    zeta    "TeX"
  2391.     
  2392.     bind    '\ '    <zo>    thin    "TeX"
  2393.     bind    '\ '    <zos>    negThin    "TeX"
  2394.     # bind    '\ '    <oz>    medium    "TeX"
  2395.     bind    '\ '    <zco>    thick    "TeX"
  2396.     bind    '\ '    <zcs>    quad    "TeX"
  2397.     bind    '\ '    <zcso>    dblQuad    "TeX"
  2398.     
  2399.     bind    ','    <zo>    lessOrEqual    "TeX"
  2400.     bind    ','    <zos>    subset    "TeX"
  2401.     # bind    ','    <oz>    subsetOrEqual    "TeX"
  2402.     bind    ','    <zco>    subscript    "TeX"
  2403.     
  2404.     bind    '.'    <zo>    greaterOrEqual    "TeX"
  2405.     bind    '.'    <zos>    superset    "TeX"
  2406.     # bind    '.'    <oz>    supersetOrEqual    "TeX"
  2407.     bind    '.'    <zco>    superscript    "TeX"
  2408.     
  2409.     bind    '/'    <zo>    divide    "TeX"
  2410.     bind    '/'    <zco>    fraction    "TeX"
  2411.     
  2412.     bind    '\;'    <zo>    ellipsis    "TeX"
  2413.     bind    '\;'    <zos>    centerDots    "TeX"
  2414.     # bind    '\;'    <oz>    verticalDots    "TeX"
  2415.     bind    '\;'    <zco>    diagonalDots    "TeX"
  2416.     
  2417.     # apostrophe:
  2418.     bind    0x27    <zco>    acuteAccent    "TeX"
  2419.     bind    0x27    <zcs>    quotes    "TeX"
  2420.     bind    0x27    <zcso>    dblQuotes    "TeX"
  2421.  
  2422.     bind    '\['    <zo>    brackets    "TeX"
  2423.     bind    '\['    <zos>    braces    "TeX"
  2424.     bind    '\['    <zco>    bigBrackets    "TeX"
  2425.     bind    '\['    <zcso>    bigBraces    "TeX"
  2426.  
  2427.     bind    '\]'    <zo>    displayStyle    "TeX"
  2428.     bind    '\]'    <zos>    textStyle    "TeX"
  2429.     # bind    '\]'    <oz>    scriptStyle    "TeX"
  2430.     bind    '\]'    <zco>    scriptscriptStyle    "TeX"
  2431.     bind    '\]'    <zcso>    bigLeftBrace    "TeX"
  2432.     
  2433.     bind    '\'    <zo>    backslash    "TeX"
  2434.     bind    '\'    <zos>    absoluteValue    "TeX"
  2435.     # bind    '\'    <oz>    setMinus    "TeX"
  2436.     bind    '\'    <zco>    bigAbsoluteValue    "TeX"
  2437.     bind    '\'    <zcs>    "oneParameter"    "TeX"
  2438.     bind    '\'    <zcso>    "twoParameters"    "TeX"
  2439.     
  2440.     bind    '`'    <zco>    graveAccent    "TeX"
  2441.     bind    '`'    <zcso>    tilde    "TeX"
  2442.     
  2443.     # Change to latexMath and latexDisplaymath, if desired:
  2444.     bind    '4'    <zco>    texMath    "TeX"
  2445.     bind    '4'    <zcso>    texDisplaymath    "TeX"
  2446.     
  2447.     bind    '5'    <zo>    infinity    "TeX"
  2448.     
  2449.     bind    '6'    <zo>    sectionMark    "TeX"
  2450.     bind    '6'    <zco>    superscript    "TeX"
  2451.     
  2452.     bind    '7'    <zo>    paragraphMark    "TeX"
  2453.     
  2454.     bind    '8'    <zo>    bullet    "TeX"
  2455.     bind    '8'    <zos>    asterisk    "TeX"
  2456.     # bind    '8'    <oz>    centerDot    "TeX"
  2457.     
  2458.     bind    '9'    <zos>    parentheses    "TeX"
  2459.     bind    '9'    <zco>    bigParentheses    "TeX"
  2460.     
  2461.     # bind    '0'    <oz>    emptySet    "TeX"
  2462.     
  2463.     bind    '-'    <zo>    similar    "TeX"
  2464.     bind    '-'    <zos>    minusOrPlus    "TeX"
  2465.     # bind    '-'    <oz>    negation    "TeX"
  2466.     bind    '-'    <zco>    subscript    "TeX"
  2467.     
  2468.     bind    '='    <zo>    notEqual    "TeX"
  2469.     bind    '='    <zos>    plusOrMinus    "TeX"
  2470.     # bind    '='    <oz>    approximate    "TeX"
  2471.     bind    '='    <zco>    bar    "TeX"
  2472.     
  2473.     bind    F5    <zo>    math    "TeX"
  2474.     bind    F5    <zos>    displaymath    "TeX"
  2475.     # bind    F5    <oz>    equation    "TeX"
  2476.     
  2477.     bind    F6    <zo>    "myArray"    "TeX"
  2478.     bind    F6    <zos>    "eqnarray"    "TeX"
  2479.     # bind    F6    <oz>    "eqnarrayStar"    "TeX"
  2480.     
  2481.     bind    F7    <zo>    "enumerate"    "TeX"
  2482.     bind    F7    <zos>    "itemize"    "TeX"
  2483.     # bind    F7    <oz>    "description"    "TeX"
  2484.     
  2485.     bind    F8    <zo>    "tabular"    "TeX"
  2486.     bind    F8    <zos>    tabbing    "TeX"
  2487.     
  2488.     bind    F9    <zo>    figure    "TeX"
  2489.     bind    F9    <zos>    table    "TeX"
  2490.     # bind    F9    <oz>    slide    "TeX"
  2491.     
  2492.     bind    F10    <zo>    verbatim    "TeX"
  2493.     bind    F10    <zos>    quote    "TeX"
  2494.     # bind    F10    <oz>    quotation    "TeX"
  2495.     bind    F10    <zco>    verse    "TeX"
  2496.     
  2497.     bind    F11    <zo>    "index"    "TeX"
  2498.     bind    F11    <zos>    "bibliography"    "TeX"
  2499.     
  2500.     bind    F12    <zo>    "general"    "TeX"
  2501.  
  2502.     # tab:
  2503.     bind    0x30    nextTabStop    "TeX"
  2504.     bind    0x30    <s>     previousTabStop    "TeX"
  2505.     
  2506. }
  2507.  
  2508. #================================================================================
  2509. # Random nonsense
  2510. #================================================================================
  2511.  
  2512. proc nextSubSection {} {
  2513.     set res [search -f 1 -r 1 -n {(section|chapter)\{} [nextLineStart [getPos]]]
  2514.     if {[string length $res]} {
  2515.         goto [lineStart [lindex $res 0]]
  2516.     } else {
  2517.         beep
  2518.     }
  2519. }
  2520. bind 'n' <zs> nextSubSection "TeX"
  2521.  
  2522. proc prevSubSection {} {
  2523.     set res [search -f 0 -r 1 -n {(section|chapter)\{} [lineStart [getPos]]]
  2524.     if {[string length $res]} {
  2525.         goto [lineStart [lindex $res 0]]
  2526.     } else {
  2527.         beep
  2528.     }
  2529. }
  2530. bind 'p' <zs> prevSubSection "TeX"
  2531.  
  2532.  
  2533. proc nextSection {} {
  2534.     set res [search -f 1 -r 1 -n {\\(section|chapter)\{} [nextLineStart [getPos]]]
  2535.     if {[string length $res]} {
  2536.         goto [lineStart [lindex $res 0]]
  2537.     } else {
  2538.         beep
  2539.     }
  2540. }
  2541. bind 'n' <zsc> nextSection "TeX"
  2542.  
  2543. proc prevSection {} {
  2544.     set res [search -f 0 -r 1 -n {\\(section|chapter)\{} [expr [lineStart [getPos]]-1]]
  2545.     if {[string length $res]} {
  2546.         goto [lineStart [lindex $res 0]]
  2547.     } else {
  2548.         beep
  2549.     }
  2550. }
  2551. bind 'p' <zsc> prevSection "TeX"
  2552.  
  2553.